package com.work.sort;

import java.util.Arrays;

public class shell {
    public static void main(String[] args) {
        int[] arr={8,9,1,7,2,3,5,4,6,0};
        shellSort(arr);

    }
    public static void shellSort(int[] arr){
        int temp;
        for (int gap=arr.length/2;gap>0;gap/=2)
        {
            for (int j=gap;j< arr.length;j++)
            {
                if (arr[j]<arr[j-gap]){
                    int i=j;
                    temp=arr[i];
                    while (i-gap>=0 && temp<arr[i-gap]){
                        arr[i]=arr[i-gap];
                        i-=gap;
                    }
                    arr[i]=temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
